
//
//  BaseTableViewController.swift
//  weibo
//
//  Created by sanya on 15/6/23.
//  Copyright © 2015年 sanya. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    
    var userLogin = sharedUserAccount != nil
//    var userLogin = false
    var visitorView:VisitorLoginView?
    
    override func loadView() {
        // 根据是否登录跳转不同的控制器
        userLogin ? super.loadView(): setupVistorView()
    }
    private func setupVistorView() {
        // 替换控制器
        visitorView = VisitorLoginView()
        visitorView?.delegate = self
        view = visitorView
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorRegisterButtonClicked")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginButtonClicked")
    }
    
    func visitorRegisterButtonClicked() {
        print("注册")
    }
    func visitorLoginButtonClicked() {
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
        
    }

}
